<template>
	<view class="content">
		<view class="navbar">
			<view v-for="(item, index) in navList" :key="index" class="nav-item"
				:class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
		</view>
		<view class="huizong">
			<view class="moneyhuizong">
				<view>
					<text style="color: #ff0000;font-weight: 600;">{{money}}</text>
				</view>
				<view>
					<text>交易金额</text>
				</view>
			</view>
			<view class="moneyhuizong">
				<view>
					<text style="color: #005500;font-weight: 600;">{{num}}</text>
				</view>
				<view>
					<text>交易订单</text>
				</view>
			</view>
		</view>
		<swiper :current="tabCurrentIndex" class="swiper-box" duration="300">
			<swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
				<scroll-view class="list-scroll-content" scroll-y>
					<view style="height: 150rpx;"></view>
					<view class="rechargemeal">
						<view :class="panduan==index ? 'meal-item-selected':'meal-item' " v-for="(item, index) in types"
							:key="index" @click="changeType(item,$event,index)">
							<view>
								<text class="t2">{{item.value}}</text>
							</view>
							<view class="t3" v-if="index==0">
								<text>金额:{{data.orderDataMoney}}</text>
							</view>
							<view class="t3" v-if="index==0">
								<text>订单:{{data.orderDataNum}}</text>
							</view>
							
							<view class="t3" v-if="index==1">
								<text>金额:{{data.rechargeDataMoney}}</text>
							</view>
							<view class="t3" v-if="index==1">
								<text>订单:{{data.rechargeDataNum}}</text>
							</view>
							
							<view class="t3" v-if="index==2">
								<text>金额:{{data.douyinDataMoney}}</text>
							</view>
							<view class="t3" v-if="index==2">
								<text>订单:{{data.douyinDataNum}}</text>
							</view>
							
							<view class="t3" v-if="index==3">
								<text>金额:{{data.meituanDataMoney}}</text>
							</view>
							<view class="t3" v-if="index==3">
								<text>订单:{{data.meituanDataNum}}</text>
							</view>
						</view>
					</view>
					<view v-for="(item, index) in orders" :key="index" class="order-item">
						<view class="iconfont icon-recharge" style="font-size: 50rpx;width: 120rpx;display: flex;justify-content: center;align-items: center;"></view>
						<view style="width: 460rpx;">
							<view class="ordername">
								<text>{{item.name}}</text>
							</view>
							<view class="ordersn">
								<text>{{item.orderSn}}</text>
							</view>
							<view class="ordersn">
								<text>{{item.createDatetime|formatDate}}</text>
							</view>
						</view>
						<view class="orderprice">
							<text>+{{item.price}}</text>
						</view>
					</view>
					<view class="more" @click="more()">
						<text>加载更多</text>
					</view>
				</scroll-view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	import Api from '@/common/api';
	// import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import uniPopupShare from "@/components/uni-popup/uni-popup-share.vue";
	import '@/static/icon/iconfont.css';
	import uniPopup from "@/components/uni-popup/uni-popup.vue"
	import empty from '@/components/empty';
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import {
		formatDate
	} from '@/common/date';
	export default {
		components: {
			// uniLoadMore,
			empty,
			uniPopupShare,
			uniPopup,
			uniLoadMore
		},
		data() {
			return {
				loadingText: '加载中...',
				loadingType: 0, //0---contentdown 1---contentrefresh  2---contentnomore
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				tabCurrentIndex: 0,
				navList: [{
						status: '0',
						text: '今日',
						loadingType: 'more',
						orderList: []
					},
					{
						status: '1',
						text: '昨天',
						loadingType: 'more',
						orderList: []
					},
					{
						status: '2',
						text: '当月',
						loadingType: 'more',
						orderList: []
					},
					{
						status: '3',
						text: '全部',
						loadingType: 'more',
						orderList: []
					},
				],
				types: [{
						name: '0',
						value: '直接消费',
					},
					{
						name: '1',
						value: '充值订单',
					},
					{
						name: '2',
						value: '抖音核销',
					},
					{
						name: '3',
						value: '美团核销',
					}
				],
				order: null,
				storeId: null,
				orders: [],
				money: 0,
				num: 0,
				panduan: 0,
				currentPage:1,
				data:null
			};
		},
		filters:{
			formatDate(time){
				if (time == null || time === '') {
					return '';
				}
				let date = new Date(time);
				return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
			}
		},
		onLoad(options) {
			this.storeId = options.storeId;
			this.loadData(options.storeId);
		},
		methods: {
			more() {
				console.log(111)
				this.currentPage++
				this.loadData(this.storeId);
			},
			async loadData(storeId) {
				console.log('当前页'+this.currentPage)
				let params = {
					status: this.tabCurrentIndex,
					storeId: storeId,
					pageNum: this.currentPage,
					payType:this.panduan
				};
				let data = await Api.apiCall('get', Api.qsg.reportdetail, params);
				if(data){
					console.log(data)
					this.money = data.totalMoney;
					this.num = data.totalNum;
					this.data = data;
					data.details.forEach(item => {
						this.orders.push(item)
					});
				}
			},
			tabClick(index) {
				this.currentPage = 1;
				this.orders = [];
				this.tabCurrentIndex = index;
				this.panduan = 0;
				this.loadData(this.storeId);
			},
			async changeType(item, e, index) {
				this.currentPage = 1;
				this.orders = [];
				this.panduan = index;
				this.loadData(this.storeId)
			},
		}
	};
</script>

<style lang="scss">
	page,
	.content {
		background: #f7f7f7;
		height: 100%;
		position: relative;
	}

	.moneyhuizong {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	}

	.tab-content {}

	.bottom-content {
		height: 600rpx;
		background-color: #ffffff;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.bottom-content-item {
		flex: 1;
	}

	.bottom-content-item-row {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.bottom-content-item-column {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.btn-primary {
		background-color: #ff9662;
		text-align: center;
		border-radius: 15rpx;
		color: #FFFFFF;
		width: 50%;
		height: 100rpx;
		line-height: 100rpx;
		margin-top: 30rpx;
	}

	.btn-default {
		/* background-color: #ff9662; */
		border: 1rpx solid #ff9662;
		text-align: center;
		border-radius: 15rpx;
		color: #ff9662;
		width: 50%;
		height: 100rpx;
		line-height: 100rpx;
		margin-bottom: 30rpx;
	}

	.item-no-select {
		background-color: #ff9662;
	}

	.uni-popup-share {
		background-color: #fff;
	}

	.uni-share-title {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		height: 40px;
	}

	.uni-share-title-text {
		font-size: 14px;
		color: #666;
	}

	.uni-share-content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		padding-top: 10px;
	}

	.uni-share-content-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
		width: 360px;
	}

	.uni-share-content-item {
		width: 90px;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		padding: 10px 0;
		align-items: center;
	}

	.uni-share-content-item:active {
		background-color: #f5f5f5;
	}

	.uni-share-image {
		width: 30px;
		height: 30px;
	}

	.uni-share-text {
		margin-top: 10px;
		font-size: 14px;
		color: #3B4144;
	}

	.uni-share-button-box {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		padding: 10px 15px;
	}

	.uni-share-button {
		flex: 1;
		border-radius: 50px;
		color: #666;
		font-size: 16px;
	}

	.uni-share-button::after {
		border-radius: 50px;
	}

	.swiper-box {
		/*  #ifdef  MP-WEIXIN  */
		height: calc(100% - 40px);
		/* #endif */
		/*  #ifdef  H5  */
		height: calc(100% - 40px);
		/* #endif */
		/*  #ifdef  MP-ALIPAY  */
		height: 1200rpx;
		/* #endif */
		padding-top: 10rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}

	.list-scroll-content {
		height: 100%;
	}
	
	.rechargemeal {
		height: auto;
		display: flex;
		flex-wrap: wrap;
		padding-left: 31rpx;
	}

	.navbar {
		display: flex;
		height: 50px;
		padding: 0 5px;
		background: #62b074;
		box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
		position: relative;
		z-index: 10;

		.nav-item {
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			height: 100%;
			font-size: 15px;
			color: #ffffff;
			position: relative;

			&.current {
				color: #ffffff;
				font-size: 20px;

				&:after {
					content: '';
					position: absolute;
					left: 50%;
					bottom: 0;
					transform: translateX(-50%);
					width: 44px;
					height: 0;
					border-bottom: 2px solid #62b074;
				}
			}
		}
	}

	.uni-swiper-item {
		height: auto;
	}
	
	.meal-item {
		position: relative;
		width: 140rpx;
		height: 140rpx;
		background: #F7F7F7;
		border: 2px solid #E8E8E8;
		border-radius: 24rpx;
		margin-right: 17rpx;
		margin-bottom: 16rpx;
		flex-direction: column;
		display: flex;
		justify-content: center;
		align-items: center;
	
		.t1 {
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			color: #5A595C;
		}
	
		.t2 {
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 600;
			color: #1A1A1A;
		}
	
		.t3 {
			height: 30rpx;
			line-height: 30rpx;
			font-size: 20rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #666666;
		}
	}
	
	.meal-item-selected {
		position: relative;
		width: 150rpx;
		height: 140rpx;
		background: #FEFAF1;
		border: 2px solid #4db590;
		border-radius: 24rpx;
		margin-right: 17rpx;
		margin-bottom: 16rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
	
		.t1 {
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			color: #5A595C;
		}
	
		.t2 {
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 600;
			color: #4db590;
		}
	
		.t3 {
			height: 30rpx;
			line-height: 30rpx;
			font-size: 20rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #EA4A33;
		}
	}

	.order-item {
		display: flex;
		padding-left: 10upx;
		background: #fff;
		margin-top: 16upx;
		border-radius: 25rpx;
		position: relative;

		.i-top {
			display: flex;
			align-items: center;
			height: 80upx;
			padding-right: 30upx;
			font-size: $font-base;
			color: $font-color-dark;
			position: relative;

			.time {
				flex: 1;
			}

			.state {
				color: $base-color;
			}

			.del-btn {
				padding: 10upx 0 10upx 36upx;
				font-size: $font-lg;
				color: $font-color-light;
				position: relative;

				&:after {
					content: '';
					width: 0;
					height: 30upx;
					border-left: 1px solid $border-color-dark;
					position: absolute;
					left: 20upx;
					top: 50%;
					transform: translateY(-50%);
				}
			}
		}

		/* 多条商品 */
		.goods-box {
			height: 160upx;
			padding: 20upx 0;
			white-space: nowrap;

			.goods-item {
				width: 120upx;
				height: 120upx;
				display: inline-block;
				margin-right: 24upx;
			}

			.goods-img {
				display: block;
				width: 100%;
				height: 100%;
			}
		}

		/* 单条商品 */
		.goods-box-single {
			display: flex;
			padding: 20upx 0;

			.goods-img {
				display: block;
				width: 220upx;
				height: 300upx;
				border-radius: 20rpx;
			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				padding: 0 30upx 0 24upx;
				overflow: hidden;

				.title {
					font-size: $font-base + 2upx;
					color: $font-color-dark;
					line-height: 1;
				}

				.attr-box {
					font-size: $font-sm + 2upx;
					color: $font-color-light;
					padding: 10upx 12upx;
				}

				.price {
					font-size: $font-base + 2upx;
					color: $font-color-dark;

					&:before {
						content: '￥';
						font-size: $font-sm;
						margin: 0 2upx 0 8upx;
					}
				}
			}
		}

		.price-box {
			display: flex;
			justify-content: flex-end;
			align-items: baseline;
			padding: 20upx 30upx;
			font-size: $font-sm + 2upx;
			color: $font-color-light;
			position: absolute;
			bottom: 5rpx;
			right: 10rpx;

			.num {
				margin: 0 8upx;
				color: $font-color-dark;
			}

			.price {
				font-size: $font-lg;
				color: $font-color-dark;

				&:before {
					content: '￥';
					font-size: $font-sm;
					margin: 0 2upx 0 8upx;
				}
			}
		}

		.action-box {
			display: flex;
			justify-content: flex-end;
			align-items: center;
			height: 100upx;
			position: relative;
			padding-right: 30upx;
		}

		.action-btn1 {
			width: 160upx;
			height: 60upx;
			margin: 0;
			margin-left: 24upx;
			padding: 0;
			text-align: center;
			line-height: 60upx;
			font-size: $font-sm + 2upx;
			color: #62b074;
			border-style: solid;
			border-width: 1rpx;
			border-color: #62b074;
			background: #fff;
			border-radius: 100px;

			&:after {
				border-radius: 100px;
			}

			&.recom {
				background: #fff9f9;
				color: $base-color;

				&:after {
					border-color: #f7bcc8;
				}
			}
		}

	}
	
	.more{
		text-align: center;
		font-size: 30rpx;
		color: #999;
	}

	.action-btn {
		width: 140upx;
		height: 40upx;
		margin: 0;
		padding: 0;
		text-align: center;
		line-height: 40upx;
		font-size: $font-sm + 2upx;
		background: #62b074;
		color: #fff9f9;
	}

	/* load-more */
	.uni-load-more {
		display: flex;
		flex-direction: row;
		height: 80upx;
		align-items: center;
		justify-content: center;
	}

	.uni-load-more__text {
		font-size: 28upx;
		color: #999;
	}

	.uni-load-more__img {
		height: 24px;
		width: 24px;
		margin-right: 10px;
	}
	
	.ordername{
		color: #62b074;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
	}
	
	.ordersn{
		color: #646464;
	}
	
	.orderprice{
		color: #62b074;
		font-size: 32rpx;
		font-family: Source Han Sans CN;
		font-weight: 500;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.uni-load-more__img>view {
		position: absolute;
	}

	.uni-load-more__img>view view {
		width: 6px;
		height: 2px;
		border-top-left-radius: 1px;
		border-bottom-left-radius: 1px;
		background: #999;
		position: absolute;
		opacity: 0.2;
		transform-origin: 50%;
		animation: load 1.56s ease infinite;
	}

	.uni-load-more__img>view view:nth-child(1) {
		transform: rotate(90deg);
		top: 2px;
		left: 9px;
	}

	.uni-load-more__img>view view:nth-child(2) {
		transform: rotate(180deg);
		top: 11px;
		right: 0;
	}

	.uni-load-more__img>view view:nth-child(3) {
		transform: rotate(270deg);
		bottom: 2px;
		left: 9px;
	}

	.uni-load-more__img>view view:nth-child(4) {
		top: 11px;
		left: 0;
	}

	.load1,
	.load2,
	.load3 {
		height: 24px;
		width: 24px;
	}

	.load2 {
		transform: rotate(30deg);
	}

	.load3 {
		transform: rotate(60deg);
	}

	.load1 view:nth-child(1) {
		animation-delay: 0s;
	}

	.load2 view:nth-child(1) {
		animation-delay: 0.13s;
	}

	.load3 view:nth-child(1) {
		animation-delay: 0.26s;
	}

	.load1 view:nth-child(2) {
		animation-delay: 0.39s;
	}

	.load2 view:nth-child(2) {
		animation-delay: 0.52s;
	}

	.load3 view:nth-child(2) {
		animation-delay: 0.65s;
	}

	.load1 view:nth-child(3) {
		animation-delay: 0.78s;
	}

	.load2 view:nth-child(3) {
		animation-delay: 0.91s;
	}

	.load3 view:nth-child(3) {
		animation-delay: 1.04s;
	}

	.load1 view:nth-child(4) {
		animation-delay: 1.17s;
	}

	.load2 view:nth-child(4) {
		animation-delay: 1.3s;
	}

	.load3 view:nth-child(4) {
		animation-delay: 1.43s;
	}

	@-webkit-keyframes load {
		0% {
			opacity: 1;
		}

		100% {
			opacity: 0.2;
		}
	}

	.huizong {
		height: 150rpx;
		width: 90%;
		background-color: #ffffff;
		display: flex;
		border-radius: 20rpx;
		position: absolute;
		z-index: 11;
		top: 80rpx;
		left: 35rpx;
	}
</style>
